<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-3.3.1.min.js"></script>
    <!--    <script src="../js/jquery.min.js"></script>-->

</head>

<body>
<script>
    function selectById(value) {
        $.ajax({
            type: "GET",
            url: "/selectCity",
            data: "id=" + value,
            success: function (json) {
                let parse = JSON.parse(json);
                $("#city").empty();
                for (let i = 0; i < parse.cityList.length; i++) {
                    var str = "<option value=" + parse.cityList[i].id + " onclick='selectById(this.value)' >" + parse.cityList[i].city + "</option>";
                    $("#city").append(str);
                }
                let pares = JSON.pares(json);
                $("#parent").empty();
                for (let i = 0; i < pares.parent.length; i++) {
                    var str = "<option value=" + pares.parent[i].id + " onclick='selectById(this.value)' >" + pares.parent[i].city + "</option>";
                    $("#parent").append(str);
                }
            },
            error: function () {
                alert("失败")
            },
            contentType: "application/json;charset=utf-8"
        })
    }

</script>

<!--<select multiple="multiple">-->
<!--    <option value="1" onclick="selectById(this.value)">河北省</option>-->
<!--    <option value="2" onclick="selectById(this.value)">湖北省</option>-->
<!--    <option value="3" onclick="selectById(this.value)">贵州省</option>-->
<!--    <option value="4" onclick="selectById(this.value)">四川省</option>-->
<!--</select>-->


<!--&lt;!&ndash;<select id="city" multiple="multiple">&ndash;&gt;-->

<!--</select>-->

<select id="parent">
    <option selected=selected>--省区--</option>
    <option value="1" onclick="selectById(this.value)">河北省</option>
    <option value="2" onclick="selectById(this.value)">湖北省</option>
    <option value="3" onclick="selectById(this.value)">贵州省</option>
    <option value="4" onclick="selectById(this.value)">四川省</option>
</select>
<select id="city">
    <option selected=selected>--城市--</option>
</select>
</body>
</html>